package cate.game.role.farm.spicefb.po;

import cate.common.table.farm.spicefb.row.SpiceFbLevelRow;
import cate.game.GameBody;
import com.fasterxml.jackson.annotation.JsonIgnore;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;

import java.util.ArrayList;
import java.util.List;

@NoteClass(value = "香料副本关卡")
public class SpiceFbLevel{
    @NoteField(value = "关卡ID")
    public int level;

    @NoteField(value = "是否通关")
    public boolean pass;

    @NoteField(value = "关卡挑战", detail = "<挑战ID>")
    public List<Integer> challenge;

    public void initialize() {
        if (challenge == null) {
            challenge = new ArrayList<>();
        }
    }

    public SpiceFbLevel(int level) {
        this.level = level;
    }

    public SpiceFbLevel() {}

    public SpiceFbLevelRow getRow(GameBody game) {
        return game.table.spiceFb.level.get(level);
    }

    /** 判断是否完美通关 */
    @JsonIgnore
    public int getStar() {
        if (!pass) {
            return 0;
        }
        return challenge.size();
    }
}
